<template>
    <div class="manage">
        <el-table
            v-loading="loading"
            :data="logs"
            style="width: 100%"
            :row-class-name="tableRowClassName">
            <el-table-column
            prop="username"
            align="center"
            sortable
            label="登录账号"
            width="180">
            </el-table-column>
            <el-table-column
            prop="lastLogin.ip"
            label="上传登入ip"
            align="center"
            width="180">
            </el-table-column>
            <el-table-column
            prop="lastLogin.loginTime"
            align="center"
            sortable
            label="上传登入时间">
            </el-table-column>
            <el-table-column
            prop="nowLogin.ip"
            align="center"
            label="本次登入ip">
            </el-table-column>
            <el-table-column
            prop="nowLogin.loginTime"
            align="center"
            label="上传登入时间">
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    import * as api from "../../../api/index"
    export default {
      data() {
          return {
              logs:[],
              loading:true
          }
      },
        created() {
            api.getLoginLogApi()
            .then(res => {
                console.log(res.data.data);
                this.logs = res.data.data
                this.loading = false
            })
        },
        methods: {
        tableRowClassName({row, rowIndex}) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
      }
    },
    }
</script>

<style scoped>
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
</style>
